$(function () {

    var start = {
        elem: '#startTime',
        format: 'YYYY-MM-DD hh:mm:ss',
        istime: true,
        choose: function (datas) {
            end.min = datas; //开始日选好后，重置结束日的最小日期
            end.start = datas //将结束日的初始值设定为开始日
        }
    }
    var end = {
        elem: '#endTime',
        format: 'YYYY-MM-DD hh:mm:ss',
        istime: true,
        choose: function (datas) {
            start.max = datas; //结束日选好后，重置开始日的最大日期
        }
    }
    laydate(start);
    laydate(end);

    queryTeacherCommissionList(1);

    $('body').on('click','#btn1,#btn2', function () {//搜索
        queryTeacherCommissionList(1);
    }).on('click','#cash-withdrawal',function () {//申请提现
        var status = check();
        if(status==true){
            commonCash(1);
        }
    }).on("click",".openInfo",function(){
    var teacherId=  $(this).data("id");
        parent.layer.open({
            type: 2,
            shadeClose: false,
            area:winArea,
            skin: 'layui-layer-demo',
            title: '分成记录',
            content: baseloaction+"/admin/qa/record/queryTeacherCommissionList?type=1&teacherId="+teacherId
        });
    });

    /**
     * 难提现
     */
    function check() {
        var status = false;
        var params = {};
        params = JSON.stringify(params);
        $.ajax({
            url:baseloaction +'/admin/qa/record/getCommissionCount',
            type:'post',
            data:params,
            dataType:'json',
            contentType:'application/json;charset=utf-8',
            async:false,
            success:function (result) {
                if(result.success==true){
                    status = true;
                }else{
                    icModale(0,result.message);
                }
            },
            error:function (error) {
                icModale(0,'系统错误，操作失败');
            }
        });
        return status;
    }

    /**
     * 查询讲师分成记录表
     * @param pageNo
     */
    function queryTeacherCommissionList(pageNo) {
        var params = $("#search-form").serializeJSON();
        params.type=typeTo;
        if(teacherId!=null&&teacherId!=0&&teacherId!=''&&typeTo=="1"){
            params.teacherId=teacherId;
        }
        params = JSON.stringify(params);
        var obj = {
            url: baseloaction + '/admin/qa/record/ajaxQueryTeacherCommissionList',//请求URLt
            contextId: 'teacher-commission-list-context',//响应内容页面设置内容ID
            params: params,//请求参数
            pageNo: pageNo,//页码
            pageCall: queryTeacherCommissionList, //分页回调加载数据(点击上下页时调用,该方法也在加载页面完成时调用)
            callback: function (pageNo) {//数据加载完成回调
                $("#count").html("(共"+ total +"条分成记录)");
            }
        };
        ajaxGetListData(obj);
    }
})